package com.tl.juc.c1;

import java.util.concurrent.TimeUnit;

public class DeamonThread {
    public static void main(String[] args) {
        Thread d1 = new Thread(() -> {
            for (int i=0;i<100;i++){
                try {
                    TimeUnit.SECONDS.sleep(1);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        });
        // 设置线程为守护线程,当主线程结束了，自己也结束
        d1.setDaemon(true);
        d1.start();
        System.out.println("主线程结束了");
    }
}
